package com.datang.springcode.internationalization;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.stereotype.Component;

import java.util.Locale;

@Component
public class Operation {
    @Autowired
    private ResourceBundleMessageSource messageSource;

    public void getInternationalization() {
        String message1 = messageSource.getMessage("content", new Object[]{"赵六", "博客园", "简体中文"}, "欢迎用户来到网站", Locale.SIMPLIFIED_CHINESE);
        String message2 = messageSource.getMessage("content", new Object[]{"李四", "博客园", "繁体中文"}, "欢迎用户来到网站", Locale.TRADITIONAL_CHINESE);
        String message3 = messageSource.getMessage("content", new Object[]{"张三", "博客园", "日语"}, "欢迎用户来到网站", Locale.JAPAN);

        System.out.println(message1);
        System.out.println(message2);
        System.out.println(message3);
    }
}
